package itheimaComD03_Votes;

import java.util.*;
public class Test {
    public static void main(String[] args) {
        String[] selects ={" 大明湖","千佛山","趵突泉","超意兴"};
        List<String> datas = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < 80; i++){
            int index = random.nextInt(selects.length);
            datas.add(selects[index]);
        }
        System.out.println(datas);
        //2统计每个景点的投票人数
        Map<String,Integer> map = new HashMap<>();
        datas.forEach(v->{//2.1查询map中是否有此景点
            if(map.containsKey(v)){
                map.put(v,map.get(v)+1);
            }
            else{
                map.put(v,1);
            }

            //2.2如果没有存入此景点
            //2.3如果有则将此景点的投票人数+1

//            3.
        });
//    打印结果
        map.forEach((k,v)->
                System.out.println(k+"---"+v));
    }
}
